/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dog.dao;

import com.dog.model.BaseEntity;
import org.hibernate.LockMode;
import org.hibernate.criterion.DetachedCriteria;

import java.io.Serializable;
import java.util.List;

/**
 * User: Kuttubek Aidaraliev
 * Date: 02.04.2010
 * Time: 08:53:00
 */
public interface DAO<T extends BaseEntity> {

    T findById(Long id);

    void delete(T entity);

    int getTotalCount();

    List<T> getByRange(int firstResult, int maxResult, String field, boolean asc);

    List<T> list();

    List<T> find(String queryString, Object value);

    Number findScalar(String sql, Object... values);

    List<T> findByNamedParameters(String queryString, String[] paramNames, Object[] values);

    List<T> findByNamedParameters(final String queryString, final String[] paramNames, final Object[] values, final int maxResult);

    List<T> findByNamedParameter(String queryString, String paramName, Object value);

    T findUniqueByNamedParameters(String queryString, String[] paramNames, Object[] values);

    T findUniqueByNamedParameter(String queryString, String paramName, Object value);

    List<T> findAllByFields(String[] names, Object[] values);

    T findByFieldScalar(String names, Object value);

    T findByFieldScalarLike(String names, Object value);

    List<T> findByFieldScalarNonUnique(String name, Object value);

    T findById(Serializable id);

    List<T> findByExample(T example);

    Serializable save(T o);

    void update(T o);

    void remove(Serializable id);

    void evict(T o);

    void lock(Object entity, LockMode lockMode);

    List<T> find(String query, Object... values);

    List<T> find(String query, int maxResult, int firstRowIndex);

    List<T> findByNamedParameters(final String sql, final List<String> paramNames, final List<Object> values, final int maxResult);

    T findUnique(String query, Object... values);

    List<T> findByNamedQuery(String queryName, Object... values);

    T findUniqueByNamedQuery(String queryName, Object... values);

    void initializeObjects(final Object proxyObject);

    List<T> findWithListParam(final String sql, String[] paramNames, Object[] params, List<Long> listParam);


    List<T> findByCriteria(DetachedCriteria criteria);

    List<T> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults);


}
